
<script type="text/javascript">
	var urlBase = "#{view.base}";
</script>
<script type="text/javascript" src="#{view.base}/web-files/js/app_usuario.js"></script>
<script type="text/javascript" src="#{view.base}/web-files/js/app_endereco.js"></script>
<script type="text/javascript">
<!--
	
	$("form#da-ex-wizard-form-cliente").ready(function(){

		if( "#{view.endereco.js.ativo}" == "1" )
			disableAddress();
		else
			enableAddress();
	
		var c = $("form#da-ex-wizard-form-cliente").validate({
			
			rules:{
				usuario_nome:{required:true,minlength:5},
				usuario_email:{required:true,email:true},
				usuario_senha:{required:true,minlength:5},
				usuario_senha2:{required:true,minlength:5,equalTo:"#usuario_senha"}
			},
			onsubmit:false
			
		});
		$("form#da-ex-wizard-form-cliente").daWizard({
			
			forwardOnly:false,
			onLeaveStep:function(e,g){return c.form()},
			onBeforeSubmit:function(){return c.form()}
			
		});
		
		$("input#usuario_nome").keyup(ajaxVerifyUserName);
		$("input#usuario_nome").change(ajaxVerifyUserName);

		$('fieldset#unidade div.da-form-row div input[type=text]').keyup(function () {
	        var strVal = $(this).val();
	        $(this).val(strVal.toUpperCase());
	    });

		// Modal CEP
		$("#da-ex-dialog-div-cep").dialog({
			autoOpen:false,
			title:"Busca de Endereço",
			modal:true,width:"640"
			/*/, buttons:[{
				text:"Close Dialog",
				click:function(){
					$(this).dialog("close")
				}
			}]//*/
		});

		// Listener Modal CEP
		$("fieldset#localizacao div.da-form-row div input[name=endereco_cep]").bind("blur",function(d){
			$("#da-ex-dialog-div-cep").dialog("option",{modal:true}).dialog("open");
			searchAddress();
			d.preventDefault();
		});
		
	});

//-->
</script>

                    	<div class="grid_3">
                        	<div class="da-panel">
                        	
                            	<div class="da-panel-header">
                            	
                                	<span class="da-panel-title">
                                        <img src="#{view.base}/web-files/images/icons/color/wand.png" alt="" />
                                        #{view.form.title.action} Cliente
                                    </span>
                                    
                                </div>
                                
                                <div class="da-panel-content">
                                	<form id="da-ex-wizard-form-cliente" class="da-form" 
                                		action="#{view.base}/#{view.form.controller}/#{view.form.action}" method="post">
                                		
                                		<input type="hidden" name="cliente_id" value="#{view.cliente.id}" />
                                		<input type="hidden" name="cliente_cliente_id" value="#{view.cliente.cliente.id}" />
                                		<input type="hidden" name="unidade_id" value="#{view.unidade.id}" />
                                		<input type="hidden" name="usuario_id" value="#{view.usuario.id}" />
                                		<input type="hidden" name="endereco_id" value="#{view.endereco.id}" />
                                		
                                		<input type="hidden" name="condominio_id" id="condominio_id" value="#{view.condominio.id}" />
                                	
                                    	<fieldset class="da-form-inline">
                                    	
                                        	<legend>Identificação</legend>
                                        	
                                        	<div class="da-form-row">
	                                        	<label>Status <span class="required">*</span></label>
	                                            <div class="da-form-item">
	                                                <div id="da-ex-buttons-radio">
	                                                    <input type="radio" id="radio1" name="cliente_ativo" value="1" #{view.cliente.ativo1} /><label for="radio1">Habilitado</label>
	                                                    <input type="radio" id="radio2" name="cliente_ativo" value="0" #{view.cliente.ativo0} /><label for="radio2">Desabilitado</label>
	                                                </div>
	                                            </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Nome <span class="required">*</span></label>
                                                <div class="da-form-item large">
                                                	<input type="text" name="cliente_nome" value="#{view.cliente.nome}" class="required" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Telefone </label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="cliente_telefone" class="telefone" value="#{view.cliente.telefone}" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Data de Nascimento </label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="cliente_data_nascimento" id="da-ex-datepicker" 
                                                		class="data-nascimento" value="#{view.cliente.data.nascimento}" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>CPF <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="cliente_cpf" class="cpf required" value="#{view.cliente.cpf}" />
                                                </div>
                                            </div>
                                            
                                        </fieldset>
                                        
                                    	<fieldset class="da-form-inline" id="localizacao">
                                    	
                                        	<legend>Localização</legend>
                                        	
                                        	<div class="da-form-row">
	                                        	<label>Reside <span class="required">*</span></label>
	                                            <div class="da-form-item">
	                                                <div id="da-ex-buttons-radio">
	                                                    <input type="radio" id="reside2" name="endereco_no_condominio" value="1" #{view.endereco.condominio.ativo1} onclick="disableAddress();" /><label for="reside2">No Condomínio</label>
	                                                    <input type="radio" id="reside1" name="endereco_no_condominio" value="0" #{view.endereco.condominio.ativo0} onclick="enableAddress();" /><label for="reside1">Fora do Condomínio</label>
	                                                </div>
	                                            </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>CEP <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="endereco_cep" value="#{view.endereco.cep}" class="cep required" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Logradouro (rua, avenida, etc...) <span class="required">*</span></label>
                                                <div class="da-form-item large">
                                                	<input type="text" name="endereco_logradouro" value="#{view.endereco.logradouro}" class="required" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Número <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="endereco_numero" value="#{view.endereco.numero}" class="required" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Complemento </label>
                                                <div class="da-form-item large">
                                                	<textarea name="endereco_complemento">#{view.endereco.complemento}</textarea>
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Bairro <span class="required">*</span></label>
                                                <div class="da-form-item large">
                                                	<input type="text" name="endereco_bairro" value="#{view.endereco.bairro}" class="required" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Cidade <span class="required">*</span></label>
                                                <div class="da-form-item large">
                                                	<input type="text" name="endereco_cidade" value="#{view.endereco.cidade}" class="required" />
                                                </div>
                                            </div>
                                            
                                            #{view.endereco.estados.select}
                                            
                                        </fieldset>
                                        
                                    	<fieldset class="da-form-inline" id="unidade">
                                    	
                                        	<legend>Unidade</legend>
                                        	
                                        	<div class="da-form-row">
                                            	<label>Bloco </label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="unidade_bloco" value="#{view.unidade.bloco}" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Torre </label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="unidade_torre" value="#{view.unidade.torre}" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Andar </label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="unidade_andar" value="#{view.unidade.andar}" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Apartamento <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                	<input type="text" name="unidade_apartamento" value="#{view.unidade.apartamento}" class="required" />
                                                </div>
                                            </div>
                                        	<div class="da-form-row">
                                            	<label>Cobertura <span class="required">*</span></label>
                                                <div class="da-form-item small">
	                                                <div id="da-ex-buttons-radio">
	                                                    <input type="radio" id="isCobertura1" name="unidade_cobertura" value="0" #{view.unidade.cobertura.ativo0} class="required" /><label for="isCobertura1">Não</label>
	                                                    <input type="radio" id="isCobertura2" name="unidade_cobertura" value="1" #{view.unidade.cobertura.ativo1} /><label for="isCobertura2">Sim</label>
	                                                </div>
                                                </div>
                                            </div>
                                            
                                        </fieldset>
                                        
                                        <fieldset class="da-form-inline">
                                        
                                        	<legend>Conta de usuário</legend>
                                        	
                                            <div class="da-form-row">
                                                <label>Email <span class="required">*</span></label>
                                                <div class="da-form-item medium">
                                                	<input type="text" name="usuario_email" value="#{view.usuario.email}" class="required email" />
                                                </div>
                                            </div>
                                            <div class="da-form-row">
                                                <label>Nome de usuário <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                    <input type="text" name="usuario_nome" value="#{view.usuario.nome}" id="usuario_nome" class="required" />
                                                    <img id="usuario_loading" src="#{view.base}/web-files/images/gif/loading.gif" 
                                                    	style="width: 26px; height: 26px; margin-left: 10px; display: none;" /> 
                                                </div>
                                            </div>
                                            
                                            #{view.usuario.tipo.permissao}
                                            
                                            <div class="da-form-row">
                                                <label>Senha <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                    <input id="usuario_senha" type="password" value="" name="usuario_senha" class="required" />
                                                </div>
                                            </div>
                                            <div class="da-form-row">
                                                <label>Confirma Senha <span class="required">*</span></label>
                                                <div class="da-form-item small">
                                                    <input type="password" name="usuario_senha2" value="" class="required" />
                                                </div>
                                            </div>
                                            
                                        </fieldset>
                                       
				                        <!-- Modal CEP -->
				                        
				                        <div id="da-ex-dialog-div-cep" style="display:none;">
				                        	
				                        	<div style="text-align: center;">
				                        	
				                        		Aguarde buscando endereço...
				                        		<br />&nbsp;<br />
				                        		<img src="#{view.base}/web-files/images/gif/loading.gif" 
                                                    	style="width: 30px; height: 30px; margin-left: 10px;" /> 
				                        	
				                        	</div>
				                        	
				                        </div>
                                        
                                    </form>
                                </div>
                                
                            </div>
                        </div>
                        
